package com.tanhua.server.controller;

import com.tanhua.model.vo.PeachVoiceVo;
import com.tanhua.server.service.PeachblossomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@RequestMapping("/peachblossom")
public class PeachblossomController {

    @Autowired
    private PeachblossomService peachblossomService;
    /**
     * @param soundFile :桃花传音，发送的语音文件
     * @return: org.springframework.http.ResponseEntity
     * @description:
     * @author: Mr.ChiZi
     * @date: 2021/11/27 3:57 下午
     */
    @PostMapping
    public ResponseEntity sendVoice(MultipartFile soundFile) throws IOException {
        //调用service发送语音
        peachblossomService.sendVoice(soundFile);
        return ResponseEntity.ok(null);
    }

    @GetMapping
    public ResponseEntity receiveVoice(){
        //调用service接收语音
        PeachVoiceVo peachVoiceVo = peachblossomService.receiveVoice();
        return ResponseEntity.ok(peachVoiceVo);
    }

}
